﻿/*
 * ========================================================================
 * Copyright(c) 2008-2010北京高阳金信信息技术有限公司, All Rights Reserved.
 * ========================================================================
 *  Web服务日志信息操作类
 * 
 * 作者：邓太华     时间：2009-11-03
 * 版本：V1.0
 * 
 * 修改者：         时间：                
 * 修改说明：
 * ========================================================================
*/

using System;
using System.Collections.Generic;

using System.Text;
using SystemServiceLogClient.logservice;
using System.Configuration;


namespace Hisuntech.SystemFramework.Log
{
    /// <summary>
    /// 服务日志客户端，可以将日志写入系统监控Web服务
    /// </summary>
    public class ServiceLogClient:LogClient 
    {
     
        /// <summary>
        /// 采用异步方式写日志到Web服务
        /// </summary>
        /// <param name="logInfo">日志信息类</param>
        /// <returns></returns>
        public override bool WriteLog(LogInfo logInfo)
        {
            //throw new NotImplementedException();
            try
            {
                SystemServiceLogClient.logservice.Service1 s = new Service1();
                s.Url = base.LogProviderPropertyValue("ServiceUrl");

                LogWorkMessage = "ServiceLogClient 已经实现\r\n服务地址配置：" + s.Url;

                s.InsertBugCompleted +=new InsertBugCompletedEventHandler(s_InsertBugCompleted);

                int iLevel = (int)logInfo.Level;
                s.InsertBugAsync(AppGuid, logInfo.Message, iLevel);
                //bool r= s.InsertBug(AppGuid, logInfo.Message, iLevel);
                return true;
              
            }
            catch (Exception ex)
            {
                base.ErrMessage = ex.Message;
            }
            return false ;
        }

        private void s_InsertBugCompleted(object sender, InsertBugCompletedEventArgs e)
        {
            object o = e.Result;
           
        }
    }
}
